home *** CD-ROM | disk | FTP | other *** search
- #!/bin/sh
- TMP=/var/log/setup/tmp
- export TEXTDOMAIN=SeTswap
- if [ ! -d $TMP ]; then
- mkdir -p $TMP
- fi
- REDIR=/dev/tty4
- NDIR=/dev/null
- crunch() {
- read STRING;
- echo $STRING;
- }
- rm -f $TMP/SeTswap $TMP/SeTswapskip
- SWAPLIST="`probe -l | fgrep "Linux swap" | sort 2> $NDIR`"
- if [ "$SWAPLIST" = "" ]; then
- dialog --title "`gettext "NO SWAP SPACE DETECTED"`" --yesno "`gettext "You have not created \
- a swap partition with Linux fdisk. \
- Do you want to continue installing without one? "`" 6 60
- if [ "$?" = "1" ]; then
- dialog --title "`gettext "ABORTING INSTALLATION"`" --msgbox "`gettext "Create a swap partition with Linux fdisk, and then try this again."`" \
- 6 40
- else
- touch $TMP/SeTswapskip
- fi
- exit
- else # there is at least one swap partition:
- echo > $TMP/swapmsg
- if [ "`echo "$SWAPLIST" | sed -n '2 p'`" = "" ]; then
- echo "`gettext "Kate OS Setup has detected a swap partition:"`" >> $TMP/swapmsg
- echo >> $TMP/swapmsg
- echo " Device Boot Start End Blocks Id System\\n" >> $TMP/swapmsg
- echo "`echo "$SWAPLIST" | sed -n '1 p'`\\n" >> $TMP/swapmsg
- echo >> $TMP/swapmsg
- echo "`gettext "Do you wish to install this as your swap partition?"`" >> $TMP/swapmsg
- dialog --title "`gettext "SWAP SPACE DETECTED"`" --cr-wrap --yesno "`cat $TMP/swapmsg`" 12 70
- REPLY=$?
- else
- echo "`gettext "Kate OS Setup has detected the following swap partitions:"`" >> $TMP/swapmsg
- echo >> $TMP/swapmsg
- echo " Device Boot Start End Blocks Id System\\n" >> $TMP/swapmsg
- echo "$SWAPLIST\\n" >> $TMP/swapmsg
- echo >> $TMP/swapmsg
- echo "`gettext "Do you wish to install these as your swap partitions? "`" >> $TMP/swapmsg
- dialog --title "SWAP SPACE DETECTED" --cr-wrap --yesno "`cat $TMP/swapmsg`" 13 70
- REPLY=$?
- fi
- rm -f $TMP/swapmsg
- if [ ! $REPLY = 0 ]; then # no
- touch $TMP/SeTswapskip
- exit 0
-
- else # yes
- if cat /proc/meminfo | grep "Swap: 0 0 0" 1> $NDIR 2> $NDIR ; then
- USE_SWAP=0 # swap is not currently mounted
- fi
-
- CURRENT_SWAP="1"
- while [ ! "`echo "$SWAPLIST" | sed -n "$CURRENT_SWAP p"`" = "" ]; do
- SWAP_PART=`probe -l | fgrep "Linux swap" | sed -n "$CURRENT_SWAP p" | crunch | cut -f 1 -d ' '`
- if ! cat /proc/swaps | grep $SWAP_PART 1> $REDIR 2> $REDIR ; then
- echo $USE_SWAP
- dialog --title "`gettext "FORMATTING SWAP PARTITION"`" --infobox "`gettext "Formatting"` \
- $SWAP_PART `gettext "as a Linux swap partition (and checking for bad blocks)..."`" 4 55
- mkswap -v1 -c $SWAP_PART 1> $REDIR 2> $REDIR
- fi
- echo "`gettext "Activating swap partition"` $SWAP_PART:"
- echo "swapon $SWAP_PART"
- swapon $SWAP_PART 1> $REDIR 2> $REDIR
- #SWAP_IN_USE="`echo "$SWAP_PART swap swap defaults 0 0"`"
- #echo "$SWAP_IN_USE" >> $TMP/SeTswap
- printf "%-16s %-16s %-11s %-16s %-3s %s\n" "$SWAP_PART" "swap" "swap" "defaults" "0" "0" >> $TMP/SeTswap
- CURRENT_SWAP="`expr $CURRENT_SWAP + 1`"
- sleep 4
- done
- echo "`gettext -e "Your swapspace has been configured. This information will\nbe added to your /etc/fstab:"`" >> $TMP/swapmsg
- echo >> $TMP/swapmsg
- cat $TMP/SeTswap >> $TMP/swapmsg
- dialog --title "`gettext "SWAP SPACE CONFIGURED"`" --exit-label OK --textbox $TMP/swapmsg 10 72
- rm $TMP/swapmsg
-
- fi
- fi